import pymysql
dbParmas = {
    'host': '127.0.0.1',
    'user': 'root',
    'password': '199802',
    'db': 'xuesheng',
    'port':3306,
    'charset':'utf8'
}
conn = pymysql.Connect(**dbParmas)
cursor = conn.cursor()
sql = "select sname,sclass from student"
try:
    cursor.execute(sql)
    #获取查询结果
    data = cursor.fetchall()

    print(data)
except Exception as e:
    print(e)
finally:
    cursor.close()
    conn.close()

